package com.example.usercenter;

public class Main {
    private static Object lock = new Object();

    public static void main(String[] args) throws InterruptedException {
        // 主线程打印A-Z
        Thread thread = new Thread(() -> {
           // 分线程打印1-26
            for (int num = 1; num <= 26; num++) {
                synchronized (lock) {
                    System.out.print(num);
                    lock.notify();
                    try {
                        lock.wait();
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        });
        thread.start();
        for (char ch = 'A'; ch <= 'Z'; ch++) {
            synchronized (lock) {
                System.out.print(ch);
                lock.notify();
                lock.wait();
            }
        }
    }
}
